home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / dirut / free2.zip / FREE.DOC < prev    next >
Text File  |  1986-12-17  |  6KB  |  142 lines

  1.  
  2.      -------------------------------------------------------------
  3.     |    FREE  v2.0  Display free disk space or RAM memory.       |
  4.     |                                  |
  5.     |    ~~~~~~~ For the PUBLIC DOMAIN by Vince Bly ~~~~~~~~      |
  6.     |                                  |
  7.     | Send comments, criticisms, and small contributions to:      |
  8.     |  Vince Bly, Nanosoft, P.O. Box 409, Ft. Belvoir, VA  22060  |
  9.      -------------------------------------------------------------
  10.  
  11.  
  12.     OVERVIEW
  13.     --------
  14.  
  15.        FREE is a small utility that displays the free space on the
  16.        current or specified disk drive or free RAM memory.  It can also
  17.        set the DOS errorlevel if the amount of free space/memory is less
  18.        than a specified amount.  The command syntax is:
  19.  
  20.        FREE [D[:]] [MINREQ] [+]
  21.  
  22.        D is the drive letter of the disk whose free space is to be
  23.        checked.  If D is "M" or "m", then the available free RAM memory
  24.        will be checked.  The ":" may be included for consistancy with
  25.        other DOS commands, but will be ignored.  That is, FREE C and
  26.        FREE C: are equivalent.    If D is not equal to "M" or "m" and does
  27.        not correspond to a drive on your system, then the message
  28.        "** Invalid Drive **" will be displayed and the DOS errorlevel
  29.        will be set to 2.
  30.  
  31.        MINREQ is the the minimum number of bytes you require.  If
  32.        the actual number of bytes free is less than MINREQ, then FREE
  33.        will set the DOS errorlevel to 1.  This can be used to control
  34.        the flow of a batch file.
  35.  
  36.        The plus sign (+) is used to indicate that more detailed data
  37.        is desired.  If detailed data is requested for a disk drive, the
  38.        information will include: the sectors per cluster, the bytes per
  39.        sector, the bytes per cluster, the total clusters, the free
  40.        clusters, the total bytes, and the free bytes.  If detailed data
  41.        is requested for RAM, the information will be: the next free
  42.        address, the top address, and the number of free bytes.    In
  43.        either case, the decimal values will be displayed followed by
  44.        their hexadecimal equivalents.
  45.  
  46.        Any (or all) options may be omitted and those included may be
  47.        in any order.  However, all options must be separated by spaces.
  48.  
  49.  
  50.  
  51.     EXAMPLES
  52.     --------
  53.  
  54.        FREE           displays free space on current drive.
  55.        FREE A           displays free space on drive A.
  56.        FREE C:           displays free space on drive C.
  57.        FREE B +        display detailed information for drive B.
  58.        FREE M           displays free RAM memory.
  59.        FREE 50000      displays free space on current drive & sets errorlevel
  60.                to 1 if less than 50,000 bytes are available.
  61.        FREE M 256000   displays free RAM & sets errorlevel 1 if < 256K free.
  62.  
  63.  
  64.     SAMPLE USE IN A BATCH FILE
  65.     --------------------------
  66.  
  67.        echo off
  68.        free m 128000
  69.        if errorlevel 1 goto tag1
  70.        bigprog
  71.        goto tag2
  72.        :tag1
  73.        echo ** Not Enough Memory to run BIGPROG **
  74.        :tag2
  75.  
  76.        This example assumes that you have some program "bigprog"
  77.        that requires, at least, 128k of free RAM to run successfully.
  78.        The batch file line  free m 128000  determines the amount of free
  79.        RAM memory and sets the DOS errorlevel to 1 if less is available.
  80.        Therefore, the batch file executes bigprog only if there's enough
  81.        memory; otherwise it gives an error message.
  82.  
  83.  
  84.     DETAILED DATA OUTPUT
  85.     --------------------
  86.  
  87.        If you issued the command  FREE C +    the output might be like
  88.        that shown below.  This data is discussed in the TECH. NOTES
  89.        section on the next page.
  90.            Drive C:
  91.         Sectors/cluster =      16 [0010]
  92.         Bytes/sector    =     512 [0200]
  93.         Bytes/cluster    =      8,192 [2000]
  94.         Total clusters    =      2,591 [0A1F]
  95.         Free clusters    =      49 [0031]
  96.         Total bytes    = 21,225,472 [143E000]
  97.         Free bytes    =    401,408 [62000]
  98.  
  99.        If you issued the command  FREE M +    the output might be like
  100.        that shown below.  This data is also discussed in TECH. NOTES.
  101.            RAM memory:
  102.         Next free addr = 417,856 [660A0]
  103.         Top address    = 655,359 [9FFFF]
  104.         Free bytes     = 237,504 [39FC0]
  105.  
  106.  
  107.     TECH. NOTES
  108.     -----------
  109.  
  110.        All FREE output goes through DOS to the standard output
  111.        device.    Therefore, FREE's output can be re-directed.
  112.  
  113.        FREE requires approximately 8K of memory to run.  If less
  114.        is available, the system will probably crash (the crash occurs
  115.        during C initialization, before the C code can do anything about
  116.        it).  The amount of free RAM displayed is corrected for the RAM
  117.        space used by FREE itself.
  118.  
  119.        The detailed output for disk drives includes the bytes per
  120.        cluster (sectors/cluster * bytes/sector).  This cluster size is
  121.        the "quantum" of disk space usage.  The space used by a file will
  122.        always be an integer multiple of the bytes per cluster.    In the
  123.        example shown above, the minimum space used by any file will be
  124.        8196 bytes.  Note that the "size" listed by DIR for a file is the
  125.        actual data size, not the amount of disk space used.
  126.  
  127.        The detailed output for RAM memory displays the next free
  128.        address, the address of the lowest unused memory location.  This
  129.        is where the Program Segment Prefix (PSP) of the next loaded
  130.        program would start.  In the example above, the PSP would start
  131.        at address 660A0 or, in segmemt:offset form 660A:0000.  The top
  132.        address is the highest RAM memory address.  Note that FREE does
  133.        not examine extended memory (EMS/EEMS).    Therefore, the value of
  134.        top address will aways be less than or equal to 9FFFF (640K).
  135.  
  136.        I have included the source code (in DeSmet C) with liberal
  137.        comments.  The method of determining free RAM has been greatly
  138.        simplified compared to an earlier version of FREE which used
  139.        the DOS SETBLOCK function.  You are welcome to incorporate any
  140.        of the routines in FREE in your own programs.    VB.  12/17/86
  141.  
  142.